import Vue from 'vue';
import axios from 'axios';
import VueAxios from 'vue-axios';

Vue.use(axios,VueAxios);

//根据前端的跨域做调整
axios.defaults.baseURL = '/api';
axios.defaults.timeout = 8000;

//接口错误拦截
axios.interceptors.response.use(config => {
  let res = config.data;
  if (res.status == 0){
    return res.data;
  }else if(res.status == 10){
    window.location.href = '/login';
  }else {
    alert(res.msg);
  }
})